package com.service.single.example.thread;

/**
 * @Author: 一休
 * @Date: 2024/12/18
 */
public class MyThread extends Thread {
    /**
     * When an object implementing interface <code>Runnable</code> is used
     * to create a thread, starting the thread causes the object's
     * <code>run</code> method to be called in that separately executing
     * thread.
     * <p>
     * The general contract of the method <code>run</code> is that it may
     * take any action whatsoever.
     *
     * @see Thread#run()
     */
    @Override
    public void run() {
        System.out.println("MyThread " + Thread.currentThread().getName());

        long i = 0L;
        while (i < 10000000000000L){
            if (Thread.currentThread().isInterrupted()){
                System.out.println(i);
                System.out.println("线程中断信号== " + Thread.currentThread().isInterrupted());
                return;
            }

            i++;
        }
        System.out.println("线程中断信号-- " + Thread.currentThread().isInterrupted());
    }
}
